package com.xyt.imei.core.config;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import com.luminary.common.framework.core.auth.AbstractTokenWebMvcConfigurerAdapter;
import com.luminary.common.framework.core.auth.TokenValidator;

@Configuration
public class InterceptorConfiguration extends AbstractTokenWebMvcConfigurerAdapter {

	public static final Logger logger = LoggerFactory.getLogger(InterceptorConfiguration.class);
	
	@Autowired
	private TokenValidator tokenValidator;
	
	@Override
	public boolean validateToken(HttpServletRequest request, HttpServletResponse response, Object handler) {
		return tokenValidator.validate(request, response, handler);
	}

	@SuppressWarnings("hiding")
	@Override
	public boolean validateRole(HttpServletRequest request, HttpServletResponse response, Object handler, List<String> role) {
		return tokenValidator.validateRole(request, response, handler, role);
	}

	@Override
	public boolean validateRoleByName(HttpServletRequest request, HttpServletResponse response, Object handler, String name) {
		return false;
	}
	
}
